<?php

$sessao = new Zend_Session_Namespace('Aluno');

Zend_Loader::loadClass('aluno','library'); 

$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$query = 'SELECT SQL_CACHE n.NRT_NOM FROM MATRICULA m, CURSOBASE cb, CURSO c, NUMEROTURMA n '
        . 'WHERE m.ALU_ID = '.$sessao->aluno['ALU_ID'].' '
        . 'AND m.CUR_ID = c.CUR_ID AND c.CBS_ID = cb.CBS_ID AND c.CUR_TRM = n.NRT_ID '
        . 'AND m.MAT_STA = 1';
$row = $db->fetchRow($query);

function actionMenu($controller,$menu){
    echo $class = ($controller == $menu) ? 'class="action"':'';
}
function actionSeta($controller,$menu){
    echo $class = ($controller == $menu) ? '<span>&#9660;</span>':'<span>&nbsp;</span>';
}

//aluno
if($this->storage->read()->TUS_ID == 2){ 
    
?>
<div class="st-tp-menu">
    <div class="content-it-br"> 
        <?php
            $img = glob('public/upload/aluno/'.$sessao->aluno['ALU_ID'].'_ead.*'); 
            if(!isset($img[0])) $img[0] = 'public/media/images/sys/avatar.png';
        ?>
        <a class="itl-conf" href="<?php echo $this->baseUrl($this->modulo.'/minhaconta/foto'); ?>">
            <img src="<?php echo $this->urlbase;?>/<?php echo $img[0]; ?>" />
        </a>
        
        <div class="br-usuario">
            <div class="nome"><?php echo $this->storage->read()->USU_NOME; ?></div>
            <span><strong>Status: <?php echo strtoupper(aluno::returnStatusAluno($sessao->aluno['ALU_ID'])); ?></strong></span> <span><strong>Turma: <?php if(isset($row['NRT_NOM'])) echo $row['NRT_NOM']; ?></strong></span>
        </div>
        
        <a class="itr-menu" onclick="if(confirm('Deseja sair?')) location = '<?php echo $this->baseUrl($this->modulo.'/auth/logout')?>';" href="javascript:void(0)">Sair</a>
        <a class="itr-conf" href="<?php echo $this->baseUrl($this->modulo.'/minhaconta'); ?>"></a>
        
    </div>
</div>

<?php 

$imgs = glob('public/upload/eadbanner/*');
if(isset($imgs[0])){
    
    $sessao = new Zend_Session_Namespace('banner');
    
    if($sessao->id == '') $sessao->id = 0;
    $total = count($imgs) - 1;
    //$rand = rand(0, $total);
    $rand = $sessao->id;
    $img = $imgs[$rand];

    if($sessao->id >= $total) $sessao->id = 0;
    else $sessao->id = $sessao->id + 1;
    
    if($img > ''){
?>

    <?php /* <img src="<?php echo $this->urlbase.'/'.$img; ?>" height="200px" width="100%" /> */ ?>
    <div class="banner" style="background-image: url('<?php echo $this->urlbase.'/'.$img; ?>');"></div>
<?php
    } 
} 
?>

<div class="st-menu"> 
    <ul>
        <li><a href="<?php echo $this->baseUrl($this->modulo.'/'); ?>" <?php echo actionMenu($this->controller,'index');?>>Início <?php echo actionSeta($this->controller,'index');?></a></li>
        <li><a href="<?php echo $this->baseUrl($this->modulo.'/materiais'); ?>" <?php echo actionMenu($this->controller,'materiais');?>>Materiais <?php echo actionSeta($this->controller,'materiais');?></a></li>
        <li><a href="<?php echo $this->baseUrl($this->modulo.'/redacao'); ?>" <?php echo actionMenu($this->controller,'redacao');?>>Redação <?php echo actionSeta($this->controller,'redacao');?></a></li>
        <li><a href="<?php echo $this->baseUrl($this->modulo.'/linkuteis'); ?>" <?php echo actionMenu($this->controller,'linkuteis');?>>Links Úteis <?php echo actionSeta($this->controller,'linkuteis');?></a></li>
        <li><a href="<?php echo $this->baseUrl($this->modulo.'/contato'); ?>" <?php echo actionMenu($this->controller,'contato');?>>Contato <?php echo actionSeta($this->controller,'contato');?></a></li>
    </ul>
</div>
    
<?php 
}else //professo
if($this->storage->read()->TUS_ID == 3){

    
function actionMenuPrf($controller,$menu){
    echo $class = ($controller == $menu) ? 'class="action"':'';
}
        
?>
    
    <div class="st-tp-menu">
        <div class="content-it-br"> 
            <?php
                //$img = glob('public/upload/aluno/'.$sessao->aluno['ALU_ID'].'_ead.*'); 
                $img = array();
                if(!isset($img[0])) $img[0] = 'public/media/images/aluno_ead.png';
            ?>
            <a class="itl-conf" href="javascript:void(0);">
                <img src="<?php echo $this->urlbase;?>/<?php echo $img[0]; ?>" />
            </a>

            <div class="br-usuario">
                <div class="nome"><?php echo $this->storage->read()->USU_NOME; ?></div>
                <span><strong>Status:</strong> Professor</span>
            </div>

            <a class="itr-menu" onclick="if(confirm('Deseja sair?')) location = '<?php echo $this->baseUrl($this->modulo.'/auth/logout')?>';" href="javascript:void(0)">Sair</a>
            <a class="itr-conf" href="<?php echo $this->baseUrl($this->modulo.'/minhaconta'); ?>"></a>

        </div>
    </div>

    <div class="st-menu-prf"> 
        <ul>
            <li><a class="m1" href="<?php echo $this->baseUrl($this->modulo.'/'); ?>" <?php echo actionMenuPrf($this->controller,'index');?>>Início</a></li>
            <li><a class="m2" href="<?php echo $this->baseUrl($this->modulo.'/repositorio'); ?>" <?php echo actionMenuPrf($this->controller,'repositorio');?>>Repositório</a></li>
            <li><a class="m3" href="<?php echo $this->baseUrl($this->modulo.'/publicacao'); ?>" <?php echo actionMenuPrf($this->controller,'2');?>>Enviar Material</a></li>
            <li><a class="m4" href="<?php echo $this->baseUrl($this->modulo.'/enviarlinks'); ?>" <?php echo actionMenuPrf($this->controller,'3');?>>Enviar Links</a></li>
            <li><a class="m5" href="<?php echo $this->baseUrl($this->modulo.'/contatoprf'); ?>" <?php echo actionMenuPrf($this->controller,'4');?>>Contato</a></li>
        </ul>
    </div>
<?php } ?>